﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace System.Windows.Navigation
{
    public static class NavigationServiceExt
    {
        public static void NavigateTo(this NavigationService nav_svc, string page)
        {
            string assembly_name = System.Reflection.Assembly.GetCallingAssembly().GetName().Name;
            Uri url = new Uri(string.Format("/{0};component/{1}", assembly_name, page), UriKind.Relative);
            nav_svc.Navigate(url);
        }

        public static void NavigateTo(this NavigationService nav_svc, string external_asembly, string page)
        {
            Uri url = new Uri(string.Format("/{0};component/{1}", external_asembly, page), UriKind.Relative);                       
            nav_svc.Navigate(url);
        }


        public static void NavigateTo(this Frame nav_svc, string page)
        {
            string assembly_name = System.Reflection.Assembly.GetCallingAssembly().GetName().Name;
            Uri url = new Uri(string.Format("/{0};component/{1}", assembly_name, page), UriKind.Relative);
            //Uri url = new Uri(string.Format("{0}", page), UriKind.Relative);   
            nav_svc.Navigate(url);
        }

        public static void NavigateTo(this Frame nav_svc, string external_asembly, string page)
        {
            Uri url = new Uri(string.Format("/{0};component/{1}", external_asembly, page), UriKind.Relative);
            nav_svc.Navigate(url);
        }
    }
}
